<template>
    <el-row>
      <el-row  :span="24" class="header">
        <el-col :offset="1">
          <span>机构借款发标</span>
        </el-col>
      </el-row>
      <el-row :span="24">
        <el-col :offset="2" :span="2" style="margin-top: 50px">
          <el-button type="primary" @click="sendpost">借款申请</el-button>
        </el-col>
        <el-col :offset="1" :span="2" style="margin-top: 50px">
          <el-button type="primary" @click="button2">发标申请</el-button>
        </el-col>
        <el-col :offset="3" :span="5" style="margin-bottom: 40px;margin-top: 80px ">
          <el-form style="text-align: right;margin-top: 20px">
            <el-form-item label="产品">
              <el-select v-model="reqbody.product_name" style="width: 200px">
                <el-option  label="慧釜贷2" :value="1"></el-option>
                <el-option  label="同岳" :value="2"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="申请id">
              <el-input style="width:200px" type="text" v-model="reqbody.apply_id"  autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="借款人">
              <el-input style="width:200px" type="text" v-model="reqbody.debtor_name"  autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="借款人身份证">
              <el-input style="width:200px" type="text" v-model="reqbody.debtor_idcard"  autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="借款人手机号">
              <el-input style="width:200px" type="text" v-model="reqbody.debtor_tel"  autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="借款金额">
              <el-input style="width:200px" type="text" v-model="reqbody.apply_amount"  autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="借款期限">
              <el-input style="width:200px" type="text" v-model="reqbody.apply_limit_d"  autocomplete="off"></el-input>
            </el-form-item>
          </el-form>
        </el-col>
        <el-col :offset="2" :span="5" style="margin-top: 100px">
          {{ResponseData}}
        </el-col>

      </el-row>
    </el-row>
</template>

<style>
  .header{
    background-color: #b9d5f1;
    color: #092b54;
    text-align: left;
    line-height: 60px;
    font-family:"list-style-type: upper-roman;";
    font-size: 20px;
    height: 70px;
  }
</style>

<script>

  export default {
    data() {
      return {
        ResponseData:'',
        reqbody:{
          apply_id:(new Date()).getTime(),
          debtor_idcard:"330902199309145582",
          debtor_name:"专用三",
          debtor_tel:"13500108690",
          product_name:"",
          apply_amount:"300",
          apply_limit_d:"180",
          client_id:'',
        },
        productName:'',
        url: 'http://tinstitutionapi.shitou.local:80/institution/institutionService/loanApply',
        body:{
          "product_name": "",
          "apply_amount": "300",
          "apply_id": (new Date()).getTime(),
          "apply_limit_d": "180",
          "debtor_idcard": "",
          "debtor_name": "专用三",
          "debtor_tel": "13500108690",
          "credit_info": {
            "asset_value": "5225555555",
            "credit_limit": "80000000000000",
            "credit_utilization_rate": "0",
            "debt_asset_ratio": "8000000",
            "loan_account": "无",
            "m12_org_credit_num": "0",
            "m12_private_credit_num": "5",
            "m24_corporate_account": "8000000",
            "m24_private_account": "85552222"
          },
          "cards":{
            "bank_id":"CCB",
            "prov_id":"0053",
            "area_id":"5307",
            "card_id":"6214664277613310219",
          },
          "debtor_type": "01",
          "files": {
            "company_basic": "https://www.shitou.com/",
            "company_business": "https://www.shitou.com/",
            "flow_files": "https://www.shitou.com/",
            "personal_files": "http://www.baidu.com,http://www.360.com,https://www.shitou.com/",
            "private_credit": "https://www.shitou.com/"
          },
          "org_loan_info": {
            "o_apply_date": "2017-05-02 15:59:59",
            "o_late_d": "2",
            "o_loan_amount": "125857",
            "o_loan_limit_m": "2",
            "o_loan_status": "放款审核中",
            "o_new_loan_limit_d": "3600",
            "o_new_repay_amount": "8000",
            "o_new_repay_principal": "320000",
            "o_repay_type": "等额本息"
          },
          "pay_files": {
            "contracts_files": "https://www.shitou.com/upload/img/00.jpg",
            "loan_ctf": "https://www.shitou.com/upload/img/11.jpg"
          },
          "pros": {
            "age": "26",
            "company_name": "上海石投",
            "company_nature": "国企",
            "education": "本科",
            "house_property": "无",
            "imcumbency_time": "10年",
            "industry": "金融",
            "marriage": "已婚",
            "sex": "男"
          },
          "province": "上海"
        },
        bodyV2:{
          "apply_id": "446848848gh64",
          "loan_amount": "300",
          "loan_limit_d": "180",
          "org_pay_date": "2017-04-25 17:36:36",
          "pay_files": {
            "contracts_files": "http://www.baidu.com,http://www.tmall.com",
            "loan_card_bank": "中国工商银行",
            "loan_card_name": "至尊1",
            "loan_card_num": "6214668888952760665",
            "loan_ctf": "http://www.baidu.com,http://www.tmall.com"
          }
        }
      }
    },
    methods:{
      sendpost:function () {
        if (this.reqbody.product_name == "1" || this.reqbody.product_name == "2"){
           if(this.reqbody.product_name == "1"){
             this.reqbody.product_name ="hfd"
             this.reqbody.client_id ="HUIFU"
           }
           if(this.reqbody.product_name == "2"){
             this.reqbody.product_name ="tyd"
             this.reqbody.client_id ="TONGY"
           }
          this.body.debtor_idcard=this.reqbody.debtor_idcard;
          this.body.debtor_name=this.reqbody.debtor_name;
          this.body.debtor_tel=this.reqbody.debtor_tel;
          this.body.product_name=this.reqbody.product_name;
          this.body.apply_amount=this.reqbody.apply_amount;
          this.body.apply_limit_d=this.reqbody.apply_limit_d;
          this.ResponseData="正在请求中......";
          this.$axios({
            url:"/tool/borrow_money",
            method:'POST',
            data:this.body,
            headers:{
              'ST-CLIENT-ID':this.reqbody.client_id
            }
          }).then(Response=>{
            this.reqbody.product_name ="";
            this.ResponseData = "借款申请："+ Response.data.msg +"        intitutionApplyId:"+Response.data.intitutionApplyId;
            console.log(Response)
            console.log(Response.data.msg)
          })
        }else {}

      },
      button2:function () {
        this.bodyV2.apply_id = this.body.apply_id;
        this.bodyV2.loan_amount = this.body.loan_amount;
        this.bodyV2.loan_limit_d = this.body.loan_limit_d;
        this.$axios({
          url:"/tool/borrow_money",
          method:'POST',
          data:this.bodyV2,
          headers:{
            'ST-CLIENT-ID':this.reqbody.client_id
          }
        }).then(Response=>{
          this.ResponseData += "               发标申请："+Response.data.msg;
        })
      }
    }
  }

</script>
